﻿using System;
using System.Collections.Generic; 
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class dltzhzs : System.Web.UI.Page
{
    protected List<Model.LotteryAnnouncement> arlist = null;
    protected string[] SSQList = null;
    protected string SSQblue = null;
    protected DataTable dtPaperList = new DataTable();
    protected int jinqiCount = 0;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            jinqiCount = 30;
            bindData(30);
        } 
    }

    protected void bindData(int maxValue)
    {

        int Count = 0;
        arlist = BLL.LotteryAnnouncement.GetPageList_Where(0, maxValue, 2, out  Count);

        if (arlist != null)
        {
            dtPaperList.Columns.Add("Id", typeof(int));
            dtPaperList.Columns.Add("Chonghao", typeof(string));
            dtPaperList.Columns.Add("Lianhao", typeof(string));
            dtPaperList.Columns.Add("Hezhi", typeof(string));
            dtPaperList.Columns.Add("Jioubi", typeof(string));
            dtPaperList.Columns.Add("Sanqubi", typeof(string));

            for (int i = 0; i < arlist.Count; i++)
            {
                DataRow newRow = dtPaperList.NewRow();
                newRow["Id"] = i + 1;
                //重号
                string[] redBall = arlist[i].LotteryNo.Split('+')[0].Split(',');
                string chonghao = "";
                int count = 0;
                int lianhaocout = 0;//连号个数
                int hezhi = 0;//和值
                int jishucount = 0;//奇数个数
                int oushucount = 0;//偶数个数
                int yiqu = 0;//一区个数
                int erqu = 0;//二区个数
                int sanqu = 0;//三区个数
                for (int m = 0; m < redBall.Length; m++)
                {
                    //计算条形图中每个数的个数
                    bindTiaoxing(int.Parse(redBall[m]));

                    if (m < (redBall.Length - 1))
                    {
                        if ((int.Parse(redBall[m]) + 1) == int.Parse(redBall[m + 1]))
                        {
                            lianhaocout++;
                        }
                    }
                    hezhi += int.Parse(redBall[m]);
                    if (int.Parse(redBall[m]) % 2 == 0)
                    {
                        oushucount++;
                    }
                    else
                    {
                        jishucount++;
                    }
                    if (int.Parse(redBall[m]) > 0 && int.Parse(redBall[m]) <= 11) { yiqu++; }
                    else if (int.Parse(redBall[m]) > 11 && int.Parse(redBall[m]) <= 22) { erqu++; }
                    else if (int.Parse(redBall[m]) > 22 && int.Parse(redBall[m]) <= 33) { sanqu++; }
                    //重号处理
                    if ((i + 1) == arlist.Count)
                    {
                        chonghao = "0";
                    }
                    else
                    {
                        string[] redBallLast = arlist[i + 1].LotteryNo.Split('+')[0].Split(',');
                        for (int n = 0; n < redBall.Length; n++)
                        {
                            if (redBall[m] == redBallLast[n])
                            {
                                count++;
                            }
                        }
                    }
                }
                chonghao = count.ToString();

                newRow["Chonghao"] = chonghao;
                newRow["Lianhao"] = (lianhaocout + 1).ToString();
                newRow["Hezhi"] = hezhi.ToString();
                newRow["Jioubi"] = jishucount + ":" + oushucount;
                newRow["Sanqubi"] = yiqu + ":" + erqu + ":" + sanqu;
                dtPaperList.Rows.Add(newRow);

            }


            string[] ssqflaglist = arlist[0].LotteryNo.Split('+');
            SSQList = ssqflaglist[0].Split(',');
            SSQblue = ssqflaglist[1];
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        jinqiCount = int.Parse(DropDownList1.SelectedValue);
        bindData(int.Parse(DropDownList1.SelectedValue));
    }
    protected int[] TiaoxingDT = new int[35];
    protected void bindTiaoxing(int data)
    {
        for (int i = 0; i < 35; i++)
        {
            if (data==(i+1))
            {
                TiaoxingDT[i] += 1;
            }
        }
    }
}